// 系列编辑保存
function editsaveModel() {
    // 获取值
    var modelname = document.getElementById("editmodelname").value
    var modelfullname = document.getElementById("editmodelfullname").value
    var modelengine = document.getElementById("editmodelengine").value
    var modeltransmission = document.getElementById("editmodeltransmission").value
    var modelid = document.getElementById("editmodelmodelid").value
    console.log("name" + modelname + "abab" + modelid)
    var dates = {
        engine: modelengine,
        fullName: modelfullname,
        modelID: modelid,
        name: modelname,
        transmission: modeltransmission
    }
    var datas = JSON.stringify(dates)
    // 后台请求
   $.ajax({
       url: 'http://192.168.0.110:8080/CarManage/updateMode',//请求后台的url
       method: 'post',//请求方式
       contentType: "application/json",
       data:datas,
       success: function (res) {
           console.log(res.msg)
           alert(res.msg)
       }
   })
   // 返回
    // 返回
    divset = document.getElementsByClassName("modelSearch");
    for (var i = 0; i < divset.length; i++) {
        divset[i].style.display = "inline";
    };
    divsetedit = document.getElementsByClassName("modelEdit");
    for (var i = 0; i < divset.length; i++) {
        divsetedit[i].style.display = "none";
    };
    divsetadd = document.getElementsByClassName("modelAdd");
    for (var i = 0; i < divset.length; i++) {
        divsetadd[i].style.display = "none";
    };
}
// 状态变化
// 品牌状态
function statusChange(validflag,modelid) {
    // 获取当前状态
    console.log(validflag);
    // 判断当前状态更改
    if(validflag === 1){
       $('#modal-input').html('确认停用');
       $('#myModal').modal('show');
        var modelstatus=0
        console.log("dianji"+modelstatus+modelid);
        changeStata(modelstatus,modelid)
    }
    else{
       $('#modal-input').html('确认启用');
       $('#myModal').modal('show');
        var modelstatus=1
        console.log("dianji"+seriestatus+seriesid);
        changeStata(seriestatus,seriesid)
    }
}
// 品牌状态更改按钮
// 切换状态
function changeStata(modelstatus,modelid) {
    $('#btn_ok').click(function(){
    $.ajax({
        url: 'http://192.168.0.110:8080/CarManage/updateModelStatus',
        method:'post',
        contentType:'application/x-www-form-urlencoded',
        data:{
            modelID:modelid,
            validFlag:modelstatus
        },
         success: function (res) {
            console.log(res.msg);
            $('#myModal').modal('hide');
            location.reload();
         }
    })
})
}